<template>
  <div class="app-container">
    <el-row :gutter="20">
      <splitpanes :horizontal="this.$store.getters.device === 'mobile'" class="default-theme">
        <!--单位会员数据-->
        <pane size="84">
          <el-col>
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
              label-width="68px">
              <el-form-item label="" prop="phone">
                <el-input v-model="queryParams.phone" placeholder="用户名/手机号码" clearable style="width: 240px"
                  @keyup.enter.native="handleQuery" />
              </el-form-item>
              <el-form-item label="" prop="status">
                <el-select v-model="queryParams.status" placeholder="类型" clearable style="width: 240px">
                  <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
                    :value="dict.value" />
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
              </el-form-item>
              <el-form-item>
                <el-button type="info" plain icon="el-icon-plus" size="small" @click="handleExport"
                  v-hasPermi="['member:unitexport']">导出</el-button>
              </el-form-item>
            </el-form>


            <el-table v-loading="loading" :data="unitMemberList" @selection-change="">
              <el-table-column label="头像" align="center" key="avatar" prop="avatar" width="120" />
              <el-table-column label="用户名" align="center" key="name" prop="name" />
              <!-- <el-table-column label="项目" align="center" key="userName" prop="userName" -->
              :show-overflow-tooltip="true" />
              <el-table-column label="身份类型" align="center" key="type" prop="type" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <span v-if="scope.row.type == 1">运动员</span>
                  <span v-if="scope.row.type == 2">教练员</span>
                  <span v-if="scope.row.type == 3">裁判员</span>
                  <span v-if="scope.row.type == 4">业余运动员</span>
                </template>
              </el-table-column>
              <el-table-column label="手机号" align="center" key="phone" prop="phone" :show-overflow-tooltip="true" />
              <!-- <el-table-column label="所属单位" align="center" key="member_unit_name" prop="member_unit_name" /> -->
              <el-table-column label="身份证号" align="center" key="identity_card" prop="identity_card" />
              <el-table-column label="加入时间" align="center" key="join_time" prop="join_time" width="160">
              </el-table-column>
              <el-form-item label="状态" prop="status">
                <el-select v-model="queryParams.status" placeholder="会员状态" clearable style="width: 240px">
                  <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
                    :value="dict.value" />
                </el-select>
              </el-form-item>
              <!-- <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
                <template slot-scope="scope" v-if="scope.row.userId !== 1">
                  <el-button size="mini" type="text" icon="el-icon-edit"
                    v-hasPermi="['system:user:edit']">修改</el-button>
                  <el-button size="mini" type="text" icon="el-icon-delete"
                    v-hasPermi="['system:user:remove']">删除</el-button>
                </template>
              </el-table-column> -->
            </el-table>

            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize" @pagination="" />
          </el-col>
        </pane>
      </splitpanes>
    </el-row>
  </div>
</template>
<script>
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { Splitpanes, Pane } from "splitpanes";
import "splitpanes/dist/splitpanes.css";
import { listunitMember } from "@/api/member/member";
export default {
  name: "member",
  dicts: [],
  components: { Treeselect, Splitpanes, Pane },
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 单位会员表格数据
      unitMemberList: null,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        phone: undefined,
        member_unit_name: undefined,
      },
    }
  },
  methods: {
    /** 查询用户列表 */
    getunitMemberList() {
      this.loading = true;
      listunitMember(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.unitMemberList = response.rows;
        this.total = response.total;
        this.loading = false;
      }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getunitMemberList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('/member/unitexport', {
        ...this.queryParams
      }, `下辖会员导出数据${new Date().getTime()}.xlsx`)
    },
  },
  created() {
    this.getunitMemberList();
  },
}
</script>